<html xmlns:th="http://www.thymeleaf.org">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	  <meta charset="UTF-8">
    <title>My JSP 'add_dept.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	  <link href="../../../../static/easyui/themes/insdep/easyui.css" rel="stylesheet" type="text/css">
	  <link href="../../../../static/easyui/themes/insdep/easyui_animation.css" rel="stylesheet" type="text/css">
	  <link href="../../../../static/easyui/themes/insdep/easyui_plus.css" rel="stylesheet" type="text/css">
	  <link href="../../../../static/easyui/themes/insdep/insdep_theme_default.css" rel="stylesheet" type="text/css">
	  <link href="../../../../static/easyui/themes/insdep/icon.css" rel="stylesheet" type="text/css">
	  <link href="../../../../static/easyui/themes/color.css" rel="stylesheet" type="text/css">

	  <link href="../../../../static/ztree/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css" >
	  <link href="../../../../static/css/common.css" rel="stylesheet" type="text/css" >

	  <script type="text/javascript" src="../../../../static/jquery/jquery.min.js"></script>
	  <script type="text/javascript" src="../../../../static/easyui/jquery.easyui.min.js"></script>
	  <script type="text/javascript" src="../../../../static/easyui/themes/insdep/jquery.insdep-extend.min.js"></script>
	  <script type="text/javascript" src="../../../../static/ztree/jquery.ztree.all.min.js"></script>
	  <script type="text/javascript" src="../../../../static/easyui/easyui-lang-zh_CN.js"></script>
	  <script type="text/javascript" src="../../../../static/kindeditor/kindeditor-all-min.js"></script>
	<style type="text/css">
		table{
			margin:auto;
		}
		input[type="text"]{
			width:85%;
			height:30px;
			border:0.5px solid gray;
		}
		#select{
			width:85%;
			height:30px;
			border:0.5px solid gray;
		}
	
		td:only-child{
			text-align:center;
			
		}
	</style>

  </head>
  
  <body> 
    <div id="div1">
    	<form  method="post" id="form">
    		<table>
    			<tr>
    				<td>部门名称:</td>
    				<td>
    					<input type="text" name="deptVO.name" value="${deptVO.name}">
    					<input type="hidden" value="${deptVO.departmentid}" name="deptVO.departmentid">
    				</td>
    			</tr>
    			<tr>
    				<td>上级部门:</td>
    				<td>
    					<select  name="deptVO.deptParentId" id="select">
    						<option value="-1">请选择上级部门</option>				
    					</select>    					
    				</td>
    			</tr>
    			<tr>
    				<td>部门描述:</td>
    				<td><textarea  cols="50" rows="5" name="deptVO.description">${deptVO.description}</textarea></td>
    			</tr>
    			<tr>
    				<td colspan="2" style="text-align: center;margin-top: 10px;">
						<a href="javascript:void(0);" id="saveBtn" class="easyui-linkbutton button-save">保存</a> 
						<a href="javascript:void(0);" id="resetBtn" class="easyui-linkbutton button-reset">重置</a>
					</td>
    			</tr>    			
    		</table>
    	</form>
    </div>
  </body>
  <script type="text/javascript">
  	$(function() {
  		$.post(
	  		"manage/position/DepartmentAction_findAll.action",
	  		function(data){
	  			if(data){
	  				var departmentId = "${deptVO.deptParentId}";	
	  				$.each(data.data,function(index,obj){
	  					var option = $("<option"+" "+ "value="+obj.departmentid+">"+obj.name+"</option>");
	  					if(departmentId && departmentId == obj.departmentid){
	  						option.attr("selected",true);
	  					}
	  					$("#select").append(option);
	  				})
	  			}
	  		},"json"
	  	);
  	
  	
			//重置按钮
			$("#resetBtn").on("click",function(event){
				$("#form").form("reset");
			});
			//保存按钮
			$("#saveBtn").on("click", function(event) {
				$("#form").form("submit", {
					url : "manage/position/DepartmentAction_saveOrUpdate.action",
					onSubmit : function() {
						//对表单进行数据校验,如果未通过校验，返回false，阻止表单提交
						return $(this).form("validate");
					
					},
					success : function(data) {
						var obj = eval("("+data+")");
						if(obj.success){
							$.messager.alert("提示",obj.message);
							parent.closeTopWindow();
						}else{
							$.messager.alert("警告",obj.message);
						}
					}
				});
			});
		});
  </script>
</html>
